SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

CREATE PROCEDURE dbo.DnnProduct_GetModuleControlsByKey
	
	@ControlKey        nvarchar(50),
	@ModuleDefId       int

AS
	SELECT *     
	FROM dbo.DnnProduct_ModuleControls
	WHERE  ((ControlKey is null and @ControlKey is null) or (ControlKey = @ControlKey))
		AND    ((ModuleDefId is null and @ModuleDefId is null) or (ModuleDefId = @ModuleDefId))
		AND    ControlType >= -1
	ORDER BY ViewOrder
GO
